package com.wan.setting;

import com.wan.core.event.EventBus;
import com.wan.net.rpc.service.ServiceProviderManager;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;

/**
 * 依赖spring的扫描器
 * @author wwh
 * @date 2022/6/21 20:19
 */
@Configuration
public class SpringScanner implements BeanPostProcessor {

    @Override
    public Object postProcessAfterInitialization(@NonNull Object bean,@NonNull String beanName) throws BeansException {
        //事件总线
        EventBus.addListener(bean);
        //RPC服务
        ServiceProviderManager.addProvider(bean);
        return bean;
    }
}
